<template>
	<view class="page" :style="{'min-height':h+'px'}">
		<image class="bg_img" src="https://i.ringzle.com/file/20240129/3931d06eaa3346c9955aa7e5e535a95b.png"
			mode="widthFix"></image>
		<view class="account" :style="{'margin-top':(mt+26)+'px'}">
			<view class="a_left">
				<view class="al_avatar" @tap="toLogin">
					<image :src="avatar"></image>
				</view>
				<view class="al_name_edit">
					<text>{{name}}</text>
					<view class="ane_edit" @tap="toTurn('/pagesMy/handerUser/handerUser',true)">
						<text>编辑</text>
						<image src="https://i.ringzle.com/file/20240129/e824a765b6c24ac6aafbb49b12c23aa9.png"></image>
					</view>
				</view>
			</view>
			<view class="a_right" @tap="toTurn('/pagesTaxi/onlineCustomers/onlineCustomers',true)">
				<image src="https://i.ringzle.com/file/20240129/e9a7984a4cc5494f999bf662cf1c7e12.png"></image>
				<view>在线客服</view>
			</view>
		</view>
		<view class="nums box">
			<view @tap="toTurn('/pagesMy/coupon/index',true)">
				<text class="num">{{coupons}}</text>
				<text>优惠券</text>
			</view>
			<view @tap="toTurn('',true)">
				<text class="num">{{points}}</text>
				<text>积分</text>
			</view>
			<view @tap="toTurn('/pagesMy/collection/collection',true)">
				<text class="num">{{collects}}</text>
				<text>收藏</text>
			</view>
			<view @tap="toTurn('/pagesMy/ThumbsList/ThumbsList',true)">
				<text class="num">{{upvotes}}</text>
				<text>点赞</text>
			</view>
		</view>
		<!-- <view class="wallet box">
			<view class="w_left">
				<view class="wl_top">
					<image src="https://i.ringzle.com/file/20240129/60f0d414e1494b8a9feeef2a8e627934.png"></image>
					<text>钱包余额</text>
				</view>
				<view class="wl_price"><span class="wlp_span">￥</span><text>{{price.toFixed(2)}}</text></view>
			</view>
			<view class="w_right" @tap="toTurn('/pagesMy/wallet/index',true)">充值/提现</view>
		</view> -->
		<view class="orders box">
			<view class="o_title">
				<text>我的订单</text>
				<view class="ot_all" @tap="toTurn('/pagesMy/order/myOrder',true)">
					<!-- <view class="ot_all" @tap="toToast"> -->
					<text>全部订单</text>
					<image src="@/static/index/steamerTicket/icon_yjt.png"></image>
				</view>
			</view>
			<view class="o_menus">
				<view v-for="(item,index) in orderMenus" :key="index"
					@tap="toTurn('/pagesMy/order/index?type='+item.type,true)">
					<image :src="item.img"></image>
					<text>{{item.text}}</text>
				</view>
			</view>
		</view>
		<view class="services box">
			<text class="s_title">更多服务</text>
			<view class="s_more">
				<view v-for="(item,index) in serviceMenus2" :key="index" @tap="toTurn(item.path,item.login,item.text)">
					<image :src="item.img"></image>
					<text>{{item.text}}</text>
					<image class="jt" src="@/static/index/steamerTicket/icon_yjt.png"></image>
				</view>

			</view>
		</view>
		<Tabbar :tabbarIndex="4" v-if="!elderVersion"></Tabbar>
		<!-- 关怀版 -->
		<Tabbar2 :tabbarIndex="2" v-else></Tabbar2>
		<GetPhoneNumber ref="phoneNumber" @loginSuccess="loginSuccess"></GetPhoneNumber>
	</view>
</template>

<script>
	import Tabbar from '@/compoments/Tabbar/tabbar.vue'
	import Tabbar2 from '@/compoments/Tabbar/tabbar2.vue'
	import GetPhoneNumber from '@/compoments/Getphonenumber/index.vue'
	export default {
		name: 'my',
		components: {
			Tabbar,
			Tabbar2,
			GetPhoneNumber
		},
		data() {
			return {
				elderVersion: uni.getStorageSync('elderVersion') || 0,
				h: uni.getSystemInfoSync().windowHeight,
				w: uni.getSystemInfoSync().windowWidth,
				mt: uni.getSystemInfoSync().statusBarHeight + 44,
				avatar: 'https://fsy.shengsi.gov.cn/file/20240730/7ead48306a1a49e598f7bb81a28c704f.png',
				name: '游客',
				coupons: 0, //优惠券数量
				points: 0, //积分数
				collects: 0, //收藏数
				upvotes: 0, //点赞数
				price: 0, //钱包余额
				orderMenus: [ //type:1 待支付、2 待使用、3 待评价、4 退款/售后
					{
						type: 1,
						img: 'https://i.ringzle.com/file/20240129/818fa751cf8d4772ac1cf818522a7f54.png',
						text: '待支付'
					},
					{
						type: 2,
						img: 'https://i.ringzle.com/file/20240129/c4ef5f92f5274dbe9e281ad509571fc3.png',
						text: '待使用'
					},
					{
						type: 3,
						img: 'https://i.ringzle.com/file/20240129/2a73e5e9afcf4d759b31e5332a21d012.png',
						text: '待评价'
					},
					{
						type: 4,
						img: 'https://i.ringzle.com/file/20240129/f3fd049aaffb4768aa115572851a2bb1.png',
						text: '退款/售后'
					}
				],
				serviceMenus2: [{
						img: 'https://i.ringzle.com/file/20240129/01220b6430f44d67b5d60fb8277cc62e.png',
						text: '常用旅客',
						path: '/pagesMy/commonInformation/index?type=my',
						login: true
					},
					{
						img: 'https://i.ringzle.com/file/20240228/49e94894ce5145e7b8776ace8b7df695.png',
						text: '浏览记录',
						path: '/pagesMy/browsingHistory/index',
						login: true
					}, {
						img: 'https://i.ringzle.com/file/20240129/b6bf1f69ba1e4b2cbb48841391be75ea.png',
						text: '商家入驻',
						path: '/pagesMy/merchantOccupancyApplication/select',
						login: true
					}, {
						img: 'https://i.ringzle.com/file/20240129/30333c2e35414cfb8f91f7c3289c58f3.png',
						text: '开发票',
						path: '/pagesMy/invoice/index',
						login: true
					}, {
						img: 'https://i.ringzle.com/file/20240319/f73486fec8594ca09605a6bef5805588.png',
						text: '每日菜价',
						path: '/pagesMy/DailyPrice/DailyPrice',
						login: false
					}, {
						img: 'https://i.ringzle.com/file/20240129/f92177064a5a4cdab1396559fe6f58b5.png',
						text: '意见反馈',
						path: '/pagesMy/complaintFeedback/dataList',
						login: true
					},
					{
						img: 'https://i.ringzle.com/file/20240605/6ab3b20c272a45d590cd5b53a38562df.png',
						text: '版本切换',
						path: '/pages/my/index',
						login: false
					}
				]
			}
		},
		onShow() {
			this.getUserInfo();
		},
		methods: {
			toLogin() {
				this.$login().then(res => {
					if (res === 0) return
					else this.$refs['phoneNumber'].show = true;
				})
			},
			toTurn(url, login, text) { //login 是否需要验证登录跳转
				if (text == '版本切换') {
					uni.setStorageSync('elderVersion', 0);
				}
				if (!url) return this.$showToast('正在开发中...');
				if (login) {
					this.$login().then(res => {
						if (res === 0) {
							uni.navigateTo({
								url
							});
						} else this.$refs['phoneNumber'].show = true;
					})
				} else {
					uni.navigateTo({
						url
					});
				}
			},
			toToast() {
				this.$showToast('正在开发中...');
			},
			getUserInfo() {
				if (uni.getStorageSync('userInfo')) {
					this.name = JSON.parse(uni.getStorageSync('userInfo')).realName;
					this.avatar = JSON.parse(uni.getStorageSync("userInfo")).headUrl;
					//获取点赞收藏数
					this.getDzScNum();
					//获取钱包余额
					// this.getWalletMoney();
				}
			},
			//登录成功回调事件
			loginSuccess() {
				this.getUserInfo();
			},
			getDzScNum() {
				this.$api.get('/api/likeAndCare/num').then(res => {
					if (res.data.code === 0) {
						this.upvotes = res.data.data.likeNum;
						this.collects = res.data.data.careNum;
					} else this.$showModal(res.data.msg);
				})
			},
			getWalletMoney() {
				this.$api.get('/api/userWalletInfo/getOne').then(res => {
					if (res.data.code === 0) {
						this.price = +res.data.data.walletAmount || 0;
					} else this.$showModal(res.data.msg);
				})
			},
		}
	}
</script>

<style scoped lang="less">
	.page {
		background: #F5F8FA;
		padding-bottom: 256rpx;
		box-sizing: border-box;

		.bg_img {
			width: 100%;
			position: absolute;
			top: 0;
			left: 0;
			z-index: 0;
		}

		.account {
			width: 100%;
			display: flex;
			justify-content: space-between;

			.a_left {
				padding: 20rpx 0 0 40rpx;
				display: flex;
				z-index: 1;

				.al_avatar {
					width: 120rpx;
					height: 120rpx;
					border-radius: 50%;
					background: #FFFFFF;
					box-sizing: border-box;

					image {
						width: 100%;
						height: 100%;
						border-radius: 50%;
					}
				}

				.al_name_edit {
					margin-left: 30rpx;
					display: flex;
					flex-direction: column;

					&>text {
						font-size: 48rpx;
						font-family: PingFang-SC, PingFang-SC;
						font-weight: bold;
						color: #111111;
						line-height: 48rpx;
					}

					.ane_edit {
						width: 156rpx;
						height: 64rpx;
						border-radius: 32rpx;
						border: 1rpx solid #D3D7DE;
						margin-top: 16rpx;
						display: flex;
						align-items: center;
						justify-content: center;

						&>text {
							font-size: 34rpx;
							font-family: PingFangSC, PingFang SC;
							font-weight: 400;
							color: #5A697C;
							line-height: 34rpx;
						}

						&>image {
							margin-left: 16rpx;
							width: 34rpx;
							height: 34rpx;
						}
					}
				}
			}

			.a_right {
				width: 84rpx;
				height: 137rpx;
				position: relative;

				&>image {
					width: 100%;
					height: 100%;
					position: relative;
					top: -16rpx;
				}

				&>view {
					width: 158rpx;
					height: 48rpx;
					background: linear-gradient(270deg, #DAF9F2 0%, #FFFFFF 100%);
					box-shadow: 0rpx 4rpx 6rpx 0rpx rgba(0, 119, 80, 0.1);
					border-radius: 36rpx;
					font-size: 34rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					color: #007466;
					text-align: center;
					line-height: 48rpx;
					position: absolute;
					right: 0;
					bottom: -16rpx;
					z-index: 1;
				}
			}
		}

		.box {
			width: calc(100% - 40rpx);
			margin: 0 20rpx;
			box-sizing: border-box;
			background: #FFFFFF;
			border-radius: 20rpx;
			position: relative;
		}

		.nums {
			margin-top: 56rpx;
			padding: 35rpx 21rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-around;

			&>view {
				width: 25%;
				display: flex;
				flex-direction: column;
				align-items: center;
				z-index: 1;

				text {
					font-size: 48rpx;
					font-family: PingFang-SC, PingFang-SC;
					font-weight: bold;
					color: #333333;
					line-height: 48rpx;

					&:last-child {
						font-size: 36rpx;
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						color: #5A697C;
						line-height: 36rpx;
						margin-top: 20rpx;
					}
				}
			}
		}

		.wallet {
			margin-top: 36rpx;
			padding: 28rpx 24rpx 34rpx 30rpx;
			background: url(https://i.ringzle.com/file/20240129/062264cb5e224845b86e4567c2ec37a6.png) no-repeat;
			background-size: 100% 100%;
			display: flex;
			justify-content: space-between;

			.w_left {
				.wl_top {
					display: flex;
					align-items: center;

					image {
						width: 40rpx;
						height: 40rpx;
					}

					text {
						margin-left: 10rpx;
						font-size: 36rpx;
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						color: #FFFFFF;
						line-height: 36rpx;
					}
				}

				.wl_price {
					margin-top: 20rpx;

					.wlp_span {
						font-size: 46rpx;
						font-family: DINAlternate, DINAlternate;
						font-weight: bold;
						color: #FFFFFF;
						line-height: 46rpx;
					}

					text {
						font-size: 60rpx;
						font-family: DINAlternate, DINAlternate;
						font-weight: bold;
						color: #FFFFFF;
						line-height: 60rpx;
						margin-left: 12rpx;
					}
				}
			}

			.w_right {
				margin-top: 26rpx;
				width: 200rpx;
				height: 72rpx;
				background: linear-gradient(270deg, #D6F6ED 0%, #FFFFFF 100%);
				border-radius: 36rpx;
				line-height: 72rpx;
				text-align: center;
				font-size: 36rpx;
				font-family: PingFang-SC, PingFang-SC;
				font-weight: bold;
				color: #007750;
			}
		}

		.orders {
			margin-top: 20rpx;
			padding: 40rpx 0;

			.o_title {
				width: 100%;
				padding: 0 24rpx;
				box-sizing: border-box;
				display: flex;
				align-items: center;
				justify-content: space-between;

				&>text {
					font-size: 48rpx;
					font-family: PingFang-SC, PingFang-SC;
					font-weight: bold;
					color: #1C1E41;
					line-height: 48rpx;
				}

				.ot_all {
					display: flex;
					align-items: center;

					&>text {
						font-size: 34rpx;
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						color: #808080;
						line-height: 28rpx;
					}

					&>image {
						margin-left: 8rpx;
						width: 24rpx;
						height: 24rpx;
					}
				}
			}

			.o_menus {
				margin-top: 36rpx;
				display: flex;
				align-items: center;
				justify-content: space-around;

				&>view {
					width: 25%;
					display: flex;
					flex-direction: column;
					align-items: center;

					image {
						width: 54rpx;
						height: 54rpx;
					}

					text {
						font-size: 36rpx;
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						color: #111111;
						line-height: 36rpx;
						margin-top: 20rpx;
					}
				}
			}
		}

		.services {
			margin: 20rpx auto 0;
			width: 710rpx;
			padding: 36rpx 24rpx 0;

			.s_title {
				font-size: 48rpx;
				font-family: PingFang-SC, PingFang-SC;
				font-weight: bold;
				color: #1C1E41;
				line-height: 48rpx;
			}

			.s_more {
				width: 100%;
				margin-top: 20rpx;

				&>view {
					height: 120rpx;
					padding: 0 7rpx;
					display: flex;
					align-items: center;

					image {
						width: 48rpx;
						height: 48rpx;
					}

					text {
						font-size: 40rpx;
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						color: #333333;
						line-height: 40rpx;
						margin-left: 32rpx;
						width: 200rpx;
						flex: 1;
					}

					.jt {
						width: 35rpx;
						height: 28rpx;
					}
				}
			}
		}
	}
</style>